# 守护线程
from threading import Thread
import time


def task():
    print('sub running')
    time.sleep(3)
    print('sub over')


if __name__ == '__main__':
    t = Thread(target=task)
    t.daemon = True
    t.start()
    print('main')

# 主线程运行结束后不会立刻结束，会等待所有非守护线程结束才结束
